/**
 * 
 */
package wangjg.xuexiban.util;

import android.os.Handler;
import android.os.Message;

/**
 * @author wangjg
 *
 */
public class FileDownCallback implements WebLoader.Callback{
	public static final int TYPE_AUDIO	=	1;
	public static final int TYPE_IMG	=	2;
	public static final int TYPE_DATA	=	3;
	
	private static final String[] typeNames = {"音频", "图片", "数据"};
	
	public static final String getTypeName(int type){
		return typeNames[type-1];
	}
	
	private Handler msgHandler;
	public int msgType;
	private Object obj;
	
	public FileDownCallback() {
	}
	
	public FileDownCallback(Handler msgHandler, int msgType) {
		this.msgHandler = msgHandler;
		this.msgType = msgType;
	}
	
	public FileDownCallback(Handler msgHandler, int msgType, Object obj) {
		this.msgHandler = msgHandler;
		this.msgType = msgType;
		this.obj = obj;
	}

	@Override
	public void handle(String status, String filePath) {
		Message message = msgHandler.obtainMessage(this.msgType, new DownloadVo(filePath, status, obj));
		msgHandler.sendMessage(message);
	}
	
	public static class DownloadVo{
		
		private DownloadVo(String filePath, String status, Object obj) {
			this.filePath = filePath;
			this.status = status;
			this.obj = obj;
		}
		
		public String filePath;
		public String status;
		public Object obj;
	}
	
}